package com.lt.exam.zhuhemoshi;



public abstract class Leaf extends Component {
    public Leaf(String name) {
        super(name);
    }

    @Override
    public void add(Component c) throws Exception {
        throw new NullPointerException("不支持该操作");
    }

    @Override
    public void remove(Component c) throws Exception {
        throw new NullPointerException("不支持该操作");
    }

    @Override
    public Component getChild(int i) throws Exception {
        throw new NullPointerException("不支持该操作");
    }

    @Override
    public  void print(){
        this.work();
    };

    @Override
    public  void work(){
        System.out.print(name+"、");
    }
}
